package com.zfy.tingshu.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author 86188
 * @version v1.0
 * @project tingshu-parent
 * @Date 2025/9/1 22:00
 * @company []
 * @description
 */
@Component
public class WeChatMpConfig {
    @Autowired
    WechatAccountConfig wechatAccountConfig;

    @Bean
    public WxMaService WxMaService(){
        WxMaDefaultConfigImpl wxMaDefaultConfig = new WxMaDefaultConfigImpl();
        wxMaDefaultConfig.setAppid(wechatAccountConfig.getAppId());
        wxMaDefaultConfig.setSecret(wechatAccountConfig.getAppSecret());
        WxMaServiceImpl wxMaService = new WxMaServiceImpl();
        wxMaService.setWxMaConfig(wxMaDefaultConfig);
        return wxMaService;
    }
}
